package com.antifly.common.controller;

import com.antifly.common.dao.SysDictDao;
import com.antifly.common.pojo.dto.SysDictDto;
import com.antifly.common.pojo.entity.SysDictDO;
import com.antifly.common.utils.RelationMapperUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author LuoJiaHui
 * @date 2023/4/25 14:14
 * @description
 */
@RestController
@RequestMapping("/sysDict")
public class SysDictController {
    @Autowired
    private SysDictDao sysDictDao;

    @GetMapping
    public List<SysDictDto> sysDictDtoList() {
        List<SysDictDO> list = sysDictDao.list();
        return list.stream().map(dict -> (SysDictDto) RelationMapperUtils.entityToDto(dict, new SysDictDto())).collect(Collectors.toList());
    }
}
